import java.awt.Color;
import java.awt.EventQueue;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;

import facade.FormFacade;
import form.Form;

import builder.CoreAssetFormBuilder;
import builder.FormBuilder;
import builder.FormDirector;
import builder.LoginDecorator;
import builder.LoginFormBuilder;
import builder.RetrieveDecorator;
import builder.UpdateDecorator;

import java.awt.BorderLayout;


public class AssetRegistryFrame extends JFrame {

	/**
	 * Launch the application.
	 */

	/**
	 * Create the frame.
	 */
    JPanel panel;
    
	public AssetRegistryFrame() {
        initialize();
        setBounds();      
        setFrame();
        addToFrame();  
	}
    
    private void initialize(){
        panel = new LoginUI(this);
        
        
        /**
         * add the panel using the loginFormBuilder
         */
        
        
        /*
        JTabbedPane assetTab = new JTabbedPane(JTabbedPane.TOP);
        
        FormFacade form = new FormFacade();
        Form[] formlist = form.create(0);
        for(int i = 0; i < formlist.length; i++){
        	assetTab.addTab("Asset", null, formlist[i], null);
        }
        this.add(assetTab);
        */
        
        /**
         * Use this for the loginBuilder
         * Still need to implement the event handler for buttons
         */
        
    	/*
        FormBuilder loginbuilder = new LoginFormBuilder();
        loginbuilder = new LoginDecorator(loginbuilder);
    	FormDirector director = new FormDirector(loginbuilder);
    	director.construct();
		panel = director.getForm();
		*/
    }

    private void addToFrame(){
        getContentPane().add(panel);
        this.repaint();      
    }

    private void setBounds(){
        panel.setBounds(0, 0, panel.getWidth(), panel.getHeight());
    }

    private void setFrame(){
        this.setTitle("Asset Registry");
        this.setSize(800, 600);
        this.setVisible(true);
        this.setResizable(false);
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    public void changePanel(JPanel newpanel){
        this.remove(this.panel);
        this.panel = newpanel;
        panel.setBounds(0, 0, panel.getWidth(), panel.getHeight());
        getContentPane().add(this.panel);
        this.repaint();    
        this.setVisible(true);
    }

}
